﻿#region Header
//
//   Project:           SilverShader - Silverlight pixel shader demo application for Coding4Fun.
//
//   Changed by:        $Author$
//   Changed on:        $Date$
//   Changed in:        $Revision$
//   Project:           $URL$
//   Id:                $Id$
//
//
//   Copyright (c) 2010 Rene Schulte
//
//   This program is open source software. Please read the License.txt.
//
#endregion

using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Effects;


namespace Schulte.Silverlight.Shader
{
   public class TransparentAlternatingScanlinesEffect : ShaderEffect
   {
      #region Properties

      public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(TransparentAlternatingScanlinesEffect), 0);
      public static readonly DependencyProperty TextureSizeProperty = DependencyProperty.Register("TextureSize", typeof(Point), typeof(TransparentAlternatingScanlinesEffect), new PropertyMetadata(new Point(512, 512), PixelShaderConstantCallback(0)));

      public Brush Input
      {
         get
         {
            return ((Brush)(this.GetValue(InputProperty)));
         }
         set
         {
            this.SetValue(InputProperty, value);
         }
      }

      /// <summary>The Size of the texture.</summary>
      public Point TextureSize
      {
         get
         {
            return ((Point)(this.GetValue(TextureSizeProperty)));
         }
         set
         {
            this.SetValue(TextureSizeProperty, value);
         }
      }

      #endregion

      #region Contructors

      public TransparentAlternatingScanlinesEffect()
      {
         PixelShader pixelShader = new PixelShader
         {
            UriSource = new Uri("/SilverShader;component/Shaders/TransparentAlternatingScanlines.ps", UriKind.Relative)
         };
         this.PixelShader = pixelShader;

         this.UpdateShaderValue(InputProperty);
         this.UpdateShaderValue(TextureSizeProperty);
      }

      #endregion
   }
}
